package cn.broadin.app.hotel.stb.impl.common;

import cn.broadin.app.hotel.stb.IPDAPK;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.webkit.JavascriptInterface;




/**
 * PDDOpenAPKCommon web页面打开apk通用类
 * @author caolm
 *
 */
public class PDAPKCommon implements IPDAPK {
	//日志tag
	private static final String TAG = "PDDOpenAPKCommon";
	//context 对象
	private Context context = null;
	
	public PDAPKCommon(Context ctx) {
		this.context = ctx;
	}
	
	@Override
	@JavascriptInterface
	public void open(String packageName, String mainActivityName) {
		Log.i(TAG, "apk is :packageName:" + packageName + ", mainActivityName:" +  mainActivityName);
		if (packageName != null && mainActivityName != null) {
			Intent mIntent = new Intent();
			ComponentName comp = new ComponentName("net.sunniwell.smartui.player", "net.sunniwell.smartui.player.PlayerActivity");
			mIntent.setComponent(comp);
			mIntent.setAction("android.intent.action.MAIN");
			mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			context.startActivity(mIntent);
		}
	}
}
